package com.chenyaowei.elasticsearch.model;

import lombok.Data;
import org.dromara.easyes.annotation.HighLight;
import org.dromara.easyes.annotation.IndexField;
import org.dromara.easyes.annotation.IndexId;
import org.dromara.easyes.annotation.IndexName;
import org.dromara.easyes.annotation.rely.Analyzer;
import org.dromara.easyes.annotation.rely.FieldStrategy;
import org.dromara.easyes.annotation.rely.FieldType;
import org.dromara.easyes.annotation.rely.IdType;

import java.math.BigDecimal;


@Data
@IndexName("product")
public class Product {

    /**
     * es中的唯一id
     * type = IdType.NONE 默认策略，id由ES生成
     */
/*    @IndexId(type = IdType.NONE)
    private String id;*/

    /**
     * skuId
     */
    @IndexId(type = IdType.CUSTOMIZE)
    private Long skuId;

    /**
     * spuId
     */
    private Long spuId;

    /**
     * spu名称
     * 不指定类型默认被创建为keyword_text类型,可进行精确查询
     */
    @HighLight(mappingField = "highlightContent")
    private String spuName;

    /**
     * sku名称
     * 指定了类型及存储/查询分词器
     * strategy = FieldStrategy.NOT_EMPTY 更新的时候的策略为 创建者不为空字符串时才更新
     */
    @HighLight(mappingField = "highlightContent")
    @IndexField(fieldType = FieldType.TEXT, analyzer = Analyzer.IK_SMART, searchAnalyzer = Analyzer.IK_MAX_WORD, strategy = FieldStrategy.NOT_EMPTY)
    private String skuName;

    /**
     * sku介绍描述
     */
    @HighLight(mappingField = "highlightContent")
    @IndexField(fieldType = FieldType.TEXT, analyzer = Analyzer.IK_SMART, searchAnalyzer = Analyzer.IK_MAX_WORD)
    private String skuDesc;

    /**
     * 品牌名称
     * 不指定类型默认被创建为keyword_text类型,可进行精确查询
     */
    @HighLight(mappingField = "highlightContent")
    private String brandName;

    /**
     * 分类名称
     * 不指定类型默认被创建为keyword_text类型,可进行精确查询
     */
    @HighLight(mappingField = "highlightContent")
    private String catalogName;

    /**
     * 默认图片
     */
    private String skuDefaultImg;

    /**
     * 标题
     */
    @HighLight(mappingField = "highlightContent")
    @IndexField(fieldType = FieldType.TEXT, analyzer = Analyzer.IK_SMART, searchAnalyzer = Analyzer.IK_MAX_WORD)
    private String skuTitle;

    /**
     * 副标题
     */
    @HighLight(mappingField = "highlightContent")
    @IndexField(fieldType = FieldType.TEXT, analyzer = Analyzer.IK_SMART, searchAnalyzer = Analyzer.IK_MAX_WORD)
    private String skuSubTitle;

    /**
     * 价格
     */
    private BigDecimal price;

    /**
     * 销量
     */
    private Long saleCount;
}
